<script>
	var pnum = {$pnum};
	{if condition="(!isset($search)) AND (!isset($cate_id))"}
	var search = 0;
	var cate_id = 0;
	var goUrl = "/{$Request.module}/ad/lst.html?page="+pnum;
	var addUrl = "{:url('ad/add')}";
	{elseif condition="(isset($cate_id)) AND ($cate_id)"/}
	var cate_id = {$cate_id};
	var search = 0;
	var goUrl = "/{$Request.module}/ad/poslist/cate_id/"+cate_id+".html?page="+pnum;
	var addUrl = "/{$Request.module}/ad/add/cate_id/"+cate_id;
	{elseif condition="(isset($search)) AND ($search)"/}
	var search = {$search};
	var cate_id = 0;
	var goUrl = "/{$Request.module}/ad/search.html?page="+pnum;
	var addUrl = "{:url('ad/add')}";
	{/if}

	$(function(){
		$("#checkAll").click(function () {
	        $("input[class='text_id']:checkbox").prop("checked", this.checked);
	    }); 
	});
</script>                          
                        
                        <table class="table table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th style="width:5%"><input type="checkbox" id="checkAll"/></th>
                                    <th style="width:20%">广告图片</th>
                                    <th style="width:20%">广告名称</th>
                                    <th style="width:15%">所属分类</th>
                                    <th style="width:5%">排序</th>
                                    <th style="width:5%">是否开启</th>
                                    <th style="width:15%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            {if condition="$list->isEmpty() == false"}
							{foreach name="list" item="v"}
                                <tr>
                                    <td><input type="checkbox" class="text_id" name="id[]" value="{$v.id}" /></td>
                                    <td><img src="{$v.ad_pic}" style="max-width: 200px; max-height: 100px;" alt=""></td>
                                    <td>{$v.ad_name}</td>
                                    <td>{$v.cate_name}</td>
                                    <td>
                                        {$v.sort}
                                    </td>
                                    <td>
                                    {switch name="v.is_on"}
                                    {case value="0"}
                                    <button class="btn btn-danger btn-xs" type="button" onclick="changeTableVal({$v.id},'is_on',this);"><i class="fa fa-times"></i></button>
                                    {/case}
                                    {case value="1"}
                                    <button class="btn btn-primary btn-xs" type="button" onclick="changeTableVal({$v.id},'is_on',this);"><i class="fa fa-check"></i></button>
                                    {/case}
                                    {/switch}
                                    </td>
                                    <td><button type="button" class="btn btn-primary btn-xs" {if condition="!isset($cate_id) || !$cate_id"}onclick="edit({$v.id},this);"{else/}onclick="editpos({$v.id},{$cate_id},this);"{/if}><i class="fa fa-pencil"></i>&nbsp;编辑</button>&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-danger btn-xs" onclick="delone({$v.id},this);"><i class="fa fa-close"></i>&nbsp;删除</button></td>
                                </tr>
							{/foreach}
							{else/}
							<tr><td colspan="6" style="text-align:center; font-size:14px;">没有找到相关数据</td></tr>
							{/if}							
                            </tbody>
                        </table>
                        <div class="row"><div class="pagination" style="float:right; margin-right:20px;">{$page}</div></div>